package com.mqy.spring.pojo;

import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @author 13159 //作者
 * @version V1.0 //版本
 * @Project 2022.3.3springRM
 * @Package com.mqy.spring.pojo
 * @Description:
 * @Date 2022/3/4 8:13//日期
 * @Motto:放下杂念,只为迎接明天更好的自己
 */
@Component
public class TestUser {
    public static void main(String[] args) throws Exception {
        Object user = createBeanWithName("user");
        System.err.println(user);
    }

    public static Object createBeanWithName(String className) throws Exception {
        Properties properties = new Properties();
        properties.load(TestUser.class.getClassLoader().getResourceAsStream("bean.properties"));
        String property = properties.getProperty(className);
        if (property!=null){
            Class<?> aClass = Class.forName(property);
            return aClass.newInstance();
        }
        return null;

    }


}
